package com.util.character;

/**
 * 字符串比较
 */
public class Compare {
    public static void main(String[] args) {
        String str = "Hello Word";
        String anotherString = "hello Word";
        Object objstr = str;
        /*以下实例中我们通过字符串函数 compareTo (string) ，compareToIgnoreCase(String) 及 compareTo(object string) 来比较两个字符串
         * 并返回字符串中第一个字母ASCII的差值。*/
        int one = str.compareTo(anotherString);
        System.out.println("不同大小写比较" + one);
        int two = str.compareToIgnoreCase(anotherString);
        System.out.println("two" + two);
        int three = str.compareTo(objstr.toString());
        System.out.println("three" + three);
    }
}
